import { Prisma } from "@prisma/generated-client";

export async function deleteUserById(
  model: Prisma.TransactionClient["user"],
  id: number
): Promise<Awaited<ReturnType<Prisma.TransactionClient["user"]["update"]>>>;
export async function deleteUserById(
  model: Prisma.TransactionClient["role"],
  id: number
): Promise<Awaited<ReturnType<Prisma.TransactionClient["role"]["update"]>>>;
export async function deleteUserById(model: any, id: number): Promise<any> {
  return model.update({ where: { id }, data: { deletedAt: new Date() } });
}

export async function deleteUsers(
  model: Prisma.TransactionClient["user"],
  ids: number[]
): Promise<Awaited<ReturnType<Prisma.TransactionClient["user"]["updateMany"]>>>;
export async function deleteUsers(
  model: Prisma.TransactionClient["role"],
  ids: number[]
): Promise<Awaited<ReturnType<Prisma.TransactionClient["role"]["updateMany"]>>>;
export async function deleteUsers(model: any, ids: number[]): Promise<any> {
  return model.updateMany({
    where: { id: { in: ids } },
    data: { deletedAt: new Date() },
  });
}

export async function forceDeleteUserById(
  model: Prisma.TransactionClient["user"],
  id: number
): Promise<Awaited<ReturnType<Prisma.TransactionClient["user"]["delete"]>>>;
export async function forceDeleteUserById(
  model: Prisma.TransactionClient["role"],
  id: number
): Promise<Awaited<ReturnType<Prisma.TransactionClient["role"]["delete"]>>>;
export async function forceDeleteUserById(
  model: any,
  id: number
): Promise<any> {
  return model.delete({ where: { id } });
}

export async function forceDeleteUsers(
  model: Prisma.TransactionClient["user"],
  ids: number[]
): Promise<Awaited<ReturnType<Prisma.TransactionClient["user"]["deleteMany"]>>>;
export async function forceDeleteUsers(
  model: Prisma.TransactionClient["role"],
  ids: number[]
): Promise<Awaited<ReturnType<Prisma.TransactionClient["role"]["deleteMany"]>>>;
export async function forceDeleteUsers(
  model: any,
  ids: number[]
): Promise<any> {
  return model.deleteMany({ where: { id: { in: ids } } });
}
